package com.nanbei.huffman;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: libs
 * @Created: 2024/7/3 16:43
 */
public class HuffmanNode {
    Character ch;  // 字符
    int freq; // 频次
    HuffmanNode left;
    HuffmanNode right;
    String code; //编码

    public HuffmanNode(Character ch) {
        this.ch = ch;
    }

    public HuffmanNode(int freq, HuffmanNode left, HuffmanNode right) {
        this.freq = freq;
        this.left = left;
        this.right = right;
    }

    int getFreq(){
        return freq;
    }

    boolean isLeaf(){
        return  left == null;
    }

    @Override
    public String toString() {
        return "Node{" +
                "ch=" + ch +
                ", freq=" + freq +
                '}';
    }
}
